//TODO 未通过
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 1e6 + 10, INF = 0x3f3f3f3f;

int n, m, x, y;
vector<string> a;
vector<int> id[1010];
int tr[N][26], fail[N], cnt[1010][1010], idx;

void insert(string& s, int i)
{
    int p = 0;
    for (char it : s) {
        int c = it - 'a';
        if (tr[p][c] == 0) tr[p][c] = ++idx;
        p = tr[p][c];
    }
    id[p].push_back(i);
}

void setfail()
{
    queue<int> q;
    for (int i = 0;i < 26;i++) if (tr[0][i]) q.push(tr[0][i]);
    while (!q.empty()) {
        int now = q.front();q.pop();
        for (int i = 0;i < 26;i++)
            if (tr[now][i]) {
                fail[tr[now][i]] = tr[fail[now]][i];
                q.push(tr[now][i]);
            } else tr[now][i] = tr[fail[now]][i];
    }
}

void init()
{
    a.clear();
    memset(tr, 0, sizeof tr);
    memset(fail, 0, sizeof fail);
    memset(cnt, 0, sizeof cnt);
    for (int i = 0;i <= idx;i++) id[i].clear();
    idx = 0;
}

void solve()
{
    init();
    cin >> n >> m;
    for (int i = 0;i < n;i++) {
        string c; cin >> c;
        a.push_back(c);
    }

    cin >> x >> y;
    for (int i = 0;i < x;i++) {
        string c;cin >> c;
        insert(c, i);
    }
    setfail();

    for (int i = 0;i < n;i++)
        for (int j = 0, p = 0;j < m;j++) {
            p = tr[p][a[i][j] - 'a'];
            int tmp = p;
            while (tmp) {
                for (int x : id[tmp])
                    if (i - x + 1 >= 0 && j - y + 1 >= 0)
                        cnt[i - x + 1][j - y + 1]++;

                tmp = fail[tmp];
            }
        }

    int ans = 0;
    for (int i = 0;i < n;i++)
        for (int j = 0;j < m;j++)
            if (cnt[i][j] == x) ans++;
    cout << ans << '\n';

}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    cin >> T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
    return 0;
}